jquery教程

推荐列表 站点导航

当前位置:首页 > jquery > jquery教程 >

iframe局部刷新的二种实现方法

来源:网络整理  作者:网友投稿  发布时间:2020-12-28 23:20
本文介绍下,实现iframe局部刷新的二种方法,这在页面中经常用到,有需要的朋友可以看看。...

需求描述:
当页面有一部分是不变的或整个页面的图片很多时,可以考虑使用局部刷新,以提高整体的下载速度与用户体验。
 
1,iframe实现局部刷新的方法一
 

复制代码 代码示例:

<script type="text/javascript">
    $(function(){
    $("#a1").click(function(){
     var name= $(this).attr("name");
     $("#iframe").attr("src",name).ready();
    })
    $("#a2").click(function(){
     var name= $(this).attr("name");
     $("#iframe").attr("src",name).ready();
    })
})
</script>
<a href="#" id="a1" name=http://www.jquerycn.cn/a_11025/"a1.html">1</a>
<a href="#" id="a2" name=http://www.jquerycn.cn/a_11025/"a2.html">2</a>
<iframe src=http://www.jquerycn.cn/a_11025/"" id="iframe"></iframe>
 

当点a1时在iframe里显示a1.html的内容,点a2时在iframe里显示a2.html的内容。
 
2,iframe实现局部刷新的方法二
 

复制代码 代码示例:

<a href=http://www.jquerycn.cn/a_11025/"a1.html" id="a1" name=http://www.jquerycn.cn/a_11025/"a1.html" target="i">1</a>
<a href=http://www.jquerycn.cn/a_11025/"a2.html" id="a2" name=http://www.jquerycn.cn/a_11025/"a2.html" target="i">2</a>
<iframe src=http://www.jquerycn.cn/a_11025/"" id="iframe" name="i"></iframe>
 

备注:
<from> 同样也有target属性,作用和<a>一样
这个方式如果<from>或<a>提交到某个Action中再跳转到a1.html中效果一样,如果在Action中有req.set或session.set,最后在iframe中同样可以显示出来。

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jq/jc/10374.shtml

相关文章
最新文章
PHP识别相片是否是颠倒的 PHP识别相片是否是颠倒的

时间:2020-12-28

python编程有哪些ide python编程有哪些ide

时间:2020-12-28

python开发工程师是做什么 python开发工程师是做什么

时间:2020-12-28

php构造函数的作用 php构造函数的作用

时间:2020-12-28

php怎么跟数据库连接 php怎么跟数据库连接

时间:2020-12-28

php实现顺序线性表 php实现顺序线性表

时间:2020-12-28

Python多重继承中的菱形继 Python多重继承中的菱形继

时间:2020-12-28

php中break的作用 php中break的作用

时间:2020-12-28

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

iframe局部刷新的二种实现方法

2020-12-28 编辑:网友投稿

需求描述:
当页面有一部分是不变的或整个页面的图片很多时,可以考虑使用局部刷新,以提高整体的下载速度与用户体验。
 
1,iframe实现局部刷新的方法一
 

复制代码 代码示例:

<script type="text/javascript">
    $(function(){
    $("#a1").click(function(){
     var name= $(this).attr("name");
     $("#iframe").attr("src",name).ready();
    })
    $("#a2").click(function(){
     var name= $(this).attr("name");
     $("#iframe").attr("src",name).ready();
    })
})
</script>
<a href="#" id="a1" name=http://www.jquerycn.cn/a_11025/"a1.html">1</a>
<a href="#" id="a2" name=http://www.jquerycn.cn/a_11025/"a2.html">2</a>
<iframe src=http://www.jquerycn.cn/a_11025/"" id="iframe"></iframe>
 

当点a1时在iframe里显示a1.html的内容,点a2时在iframe里显示a2.html的内容。
 
2,iframe实现局部刷新的方法二
 

复制代码 代码示例:

<a href=http://www.jquerycn.cn/a_11025/"a1.html" id="a1" name=http://www.jquerycn.cn/a_11025/"a1.html" target="i">1</a>
<a href=http://www.jquerycn.cn/a_11025/"a2.html" id="a2" name=http://www.jquerycn.cn/a_11025/"a2.html" target="i">2</a>
<iframe src=http://www.jquerycn.cn/a_11025/"" id="iframe" name="i"></iframe>
 

备注:
<from> 同样也有target属性,作用和<a>一样
这个方式如果<from>或<a>提交到某个Action中再跳转到a1.html中效果一样,如果在Action中有req.set或session.set,最后在iframe中同样可以显示出来。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jq/jc/10374.shtml

相关文章

风云图片

推荐阅读

返回jquery教程频道首页